package com.ruoyi.web.controller.youxuan;

import java.util.List;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.YouxuanMerchants;
import com.ruoyi.system.service.IYouxuanMerchantsService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 自提点管理Controller
 * 
 * @author ruoyi
 * @date 2021-01-29
 */
@RestController
@RequestMapping("/youxuan/merchants")
public class YouxuanMerchantsController extends BaseController
{
    @Autowired
    private IYouxuanMerchantsService youxuanMerchantsService;

    /**
     * 查询自提点管理列表
     */
    @PreAuthorize("@ss.hasPermi('youxuan:merchants:list')")
    @GetMapping("/list")
    public TableDataInfo list(YouxuanMerchants youxuanMerchants)
    {
        startPage();
        List<YouxuanMerchants> list = youxuanMerchantsService.selectYouxuanMerchantsList(youxuanMerchants);
        return getDataTable(list);
    }

    /**
     * 导出自提点管理列表
     */
    @PreAuthorize("@ss.hasPermi('youxuan:merchants:export')")
    @Log(title = "自提点管理", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(YouxuanMerchants youxuanMerchants)
    {
        List<YouxuanMerchants> list = youxuanMerchantsService.selectYouxuanMerchantsList(youxuanMerchants);
        ExcelUtil<YouxuanMerchants> util = new ExcelUtil<YouxuanMerchants>(YouxuanMerchants.class);
        return util.exportExcel(list, "merchants");
    }

    /**
     * 获取自提点管理详细信息
     */
    @PreAuthorize("@ss.hasPermi('youxuan:merchants:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(youxuanMerchantsService.selectYouxuanMerchantsById(id));
    }

    /**
     * 新增自提点管理
     */
    @PreAuthorize("@ss.hasPermi('youxuan:merchants:add')")
    @Log(title = "自提点管理", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody YouxuanMerchants youxuanMerchants)
    {
        return toAjax(youxuanMerchantsService.insertYouxuanMerchants(youxuanMerchants));
    }

    /**
     * 修改自提点管理
     */
    @PreAuthorize("@ss.hasPermi('youxuan:merchants:edit')")
    @Log(title = "自提点管理", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody YouxuanMerchants youxuanMerchants)
    {
        return toAjax(youxuanMerchantsService.updateYouxuanMerchants(youxuanMerchants));
    }

    /**
     * 删除自提点管理
     */
    @PreAuthorize("@ss.hasPermi('youxuan:merchants:remove')")
    @Log(title = "自提点管理", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(youxuanMerchantsService.deleteYouxuanMerchantsByIds(ids));
    }
}
